<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //创建表格元素
    var tb = document.createElement("table");
    tb.setAttribute("border",1);
    tb.setAttribute("height","280px");
    tb.setAttribute("width","500px");
    tb.setAttribute("cellSpacing",0);
    //创建行
    for(var i=0;i<7;i++){
        var trObj = document.createElement("tr");
        for(var j=0;j<5;j++){
            //创建单元格
            var tdObj = document.createElement("td");
            if(j==0){
                tdObj.style.width = "120px";
                var btn = document.createElement("button");
                btn.innerText = "点击我删除第"+i+"行";
                tdObj.appendChild(btn);
                btn.onclick = function(){
                    tb.removeChild(this.parentNode.parentNode);
                }
            }
            trObj.appendChild(tdObj);
        }  
        tb.appendChild(trObj);
    }
    document.body.appendChild(tb);
</script>
</html>